export default  {
	namespaced:true,
	state:{
		// 收货地址
		address:JSON.parse(uni.getStorageSync('address') || '{}'),
		token:uni.getStorageSync('token') || '',
		// 用户信息
		userinfo:JSON.parse(uni.getStorageSync('userinfo') || '{}'),
		// 重定向的 Object对象
		redirectInfo:null
	},
	mutations:{
		// 更新收货地址
		updateAddress(state,address){
			state.address = address,
			this.commit('m_user/saveAddressToStorage')
		},
		// 持久化存储地址
		saveAddressToStorage(state){
			uni.setStorageSync('address',JSON.stringify(state.address))
		},
		// 更新用户信息
		updateUserInfo(state,userinfo){
			state.userinfo = userinfo	,
			this.commit('m_user/saveUserInfoToStorage')
		},
		// 持久化存储用户信息
		saveUserInfoToStorage(state){
			uni.setStorageSync('userinfo',JSON.stringify(state.userinfo))
		},
		// 更新token
		updateToken(state,token){
			state.token = token,
			this.commit('m_user/saveTokenToStorage')
		},
		// 持久化存储token
		saveTokenToStorage(state){
			uni.setStorageSync('token',state.token)
		},
		// 更新重定向消息
		updateRdirectInfo(state,info){
			state.redirectInfo = info
		
		}
	},
	getters:{
		addstr(state){
			if(state.address.provinceName == ''){
				return ''
			}else{
				return state.address.provinceName + state.address.cityName + state.address.countyName + state.address.detailInfo
			}
		}
	}
	
}